#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    connect(ui->redSlider, &QSlider::valueChanged, this, &Widget::valueChanged);
    connect(ui->greenSlider, &QSlider::valueChanged, this, &Widget::valueChanged);
    connect(ui->blueSlider, &QSlider::valueChanged, this, &Widget::valueChanged);
    connect(ui->alphaSlider, &QSlider::valueChanged, this, &Widget::valueChanged);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::valueChanged(int value)
{
    Q_UNUSED(value)
    QPalette pal = ui->textEdit->palette();
    QColor color;
    color.setRgb(ui->redSlider->value(), ui->greenSlider->value(), ui->blueSlider->value(), ui->alphaSlider->value());
    ui->rLab->setText(QString("%1").arg(ui->redSlider->value()));
    ui->gLab->setText(QString("%1").arg(ui->greenSlider->value()));
    ui->bLab->setText(QString("%1").arg(ui->blueSlider->value()));
    ui->aLab->setText(QString("%1").arg(ui->alphaSlider->value()));
    pal.setColor(QPalette::Base, color);
    ui->textEdit->setPalette(pal);
}

void Widget::on_horSlider_valueChanged(int value)
{
    ui->horScrollBar->setValue(value);
    ui->horProgressBar->setValue(value);
}


void Widget::on_horScrollBar_valueChanged(int value)
{
    ui->horSlider->setValue(value);
    ui->horProgressBar->setValue(value);
}


void Widget::on_verScrollBar_valueChanged(int value)
{
    ui->verProgressBar->setValue(value);
    ui->verSlider->setValue(value);
}


void Widget::on_verSlider_valueChanged(int value)
{
    ui->verProgressBar->setValue(value);
    ui->verScrollBar->setValue(value);
}


void Widget::on_dial_valueChanged(int value)
{
    ui->lcdNumber->display(value);
}


void Widget::on_tenRadioBtn_clicked()
{
    ui->lcdNumber->setDecMode();
}


void Widget::on_binRadioBtn_clicked()
{
    ui->lcdNumber->setBinMode();
}


void Widget::on_eitRadioBtn_clicked()
{
    ui->lcdNumber->setOctMode();
}


void Widget::on_hexRadioBtn_clicked()
{
    ui->lcdNumber->setMode(QLCDNumber::Hex);
}

